package dao;

import model.Report_in;
import model.Report_out;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

public class Dao_reportIn extends Dao {
    //获取入库报表视图
    public static List select_inAll() {
        List list = new ArrayList();
        String sql = "select distinct * from report_in group by i_time";

        ResultSet re = executeQuery(sql);
        try {
            while (re.next()) {
                Report_in report_in = new Report_in();

                report_in.setI_no((re.getString("i_no")));
                report_in.setC_name(re.getString("c_name"));
                report_in.setCs_name(re.getString("cs_name"));
                report_in.setI_number(re.getString("i_number"));
                report_in.setI_time(re.getString("i_time"));
                report_in.setNumber(re.getString("number"));

                list.add(report_in);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return list;
    }


        //通过日期获取入库报表
    public static List select_in(String inTime)
    {
        List list = new ArrayList();
        String sql = "select * from report_in where i_time = '" + inTime + "'";

        ResultSet re = executeQuery(sql);
        try {
            while (re.next())
            {
                Report_in report_in = new Report_in();

                report_in.setI_no((re.getString("i_no")));
                report_in.setC_name(re.getString("c_name"));
                report_in.setCs_name(re.getString("cs_name"));
                report_in.setI_number(re.getString("i_number"));
                report_in.setI_time(re.getString("i_time"));
                report_in.setNumber(re.getString("number"));

                list.add(report_in);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return list;
    }

    //获取入库时间
    public static Vector<String> getTime()
    {
        List list = Dao_reportIn.select_inAll();
        Vector<String> WareID = new Vector<>();

        for(int i = 0; i < list.size(); i++)
        {
            Report_in report_in = (Report_in) list.get(i);
            WareID.add(report_in.getI_time());
        }

        return WareID;
    }
}


